package com.hspedu.newData.dmsxl.位运算;

import org.junit.Test;

import java.util.HashSet;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-06 
 * @Version: 1.0
 */

public class LC只出现一次的数字Ⅲ {

    // todo
    // 位运算
    public int[] singleNumber(int[] nums) {

        HashSet<Integer> set = new HashSet<>();

        for (int num : nums) {
            if (set.contains(num)){
                set.remove(num);
            }else {
                set.add(num);
            }
        }

        int[] res = new int[2];
        int i = 0;
        for (Integer integer : set) {
            res[i++] = integer;
        }
        return res;
    }

    @Test
    public void test() {
        // 测试代码

        singleNumber(new int[]{1,2,1,3,2,5});
    }
}
